package com.threebrothers.lib_mvi.base

import androidx.lifecycle.ViewModel
import com.threebrothers.lib_mvi.IIntent
import com.threebrothers.lib_mvi.IViewModel
import kotlinx.coroutines.channels.Channel

/**
 * BaseViewModel封装
 */

abstract class BaseViewModel<I:IIntent> : ViewModel() , IViewModel<I> {
    protected val _intents = Channel<I> { Channel.UNLIMITED }

    override val intents: Channel<I>
        get() = _intents

    init {
        handleIntent()
    }

    /**
     * 根据不同的意图处理行为
     */
    abstract fun handleIntent()
}
